# TODO: We could do automatic discovery, but there are a lot of .cc files (from thirdparty) that
#       we don't want to build

set(LATIN_IME_JNI_INCLUDE
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}/src)

set(LATIN_IME_JNI_SRC_FILES
        ${CMAKE_CURRENT_SOURCE_DIR}/src/jni_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/org_futo_inputmethod_keyboard_ProximityInfo.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/org_futo_inputmethod_latin_BinaryDictionary.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/org_futo_inputmethod_latin_BinaryDictionaryUtils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/org_futo_inputmethod_latin_DicTraverseSession.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/org_futo_inputmethod_latin_xlm_LanguageModel.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/org_futo_inputmethod_latin_xlm_AdapterTrainer.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/org_futo_inputmethod_latin_xlm_ModelInfoLoader.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/org_futo_voiceinput_WhisperGGML.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/jni_common.cpp)

set(LATIN_IME_CORE_INCLUDE
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}/src
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/builtin_pb
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/esaxx
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/darts_clone
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/absl)

set(LATIN_IME_CORE_SRC_FILES
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/context.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/ggml.c
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/ggml-alloc.c
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/ggml-quants.c
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/ggml-backend.c
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/llama.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/whisper.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/finetune.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/train.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/common.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/LanguageModel.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/ggml/ModelMeta.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/arena.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/arenastring.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/bytestream.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/coded_stream.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/common.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/extension_set.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/generated_enum_util.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/generated_message_table_driven_lite.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/generated_message_util.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/implicit_weak_message.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/int128.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/io_win32.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/message_lite.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/parse_context.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/repeated_field.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/status.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/statusor.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/stringpiece.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/stringprintf.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/structurally_valid.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/strutil.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/time.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/wire_format_lite.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/zero_copy_stream.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/zero_copy_stream_impl.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf-lite/zero_copy_stream_impl_lite.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/builtin_pb/sentencepiece_model.pb.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/builtin_pb/sentencepiece.pb.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/bpe_model.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/char_model.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/error.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/filesystem.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/model_factory.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/model_interface.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/normalizer.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/sentencepiece_processor.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/unigram_model.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/util.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/sentencepiece/word_model.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/header/header_policy.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/header/header_read_write_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/property/ngram_context.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/dictionary_structure_with_buffer_policy_factory.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/pt_common/bigram/bigram_list_read_write_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/pt_common/dynamic_pt_gc_event_listeners.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/pt_common/dynamic_pt_reading_helper.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/pt_common/dynamic_pt_reading_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/pt_common/dynamic_pt_updating_helper.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/pt_common/dynamic_pt_writing_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/pt_common/patricia_trie_reading_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/pt_common/shortcut/shortcut_list_reading_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v2/patricia_trie_policy.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v2/ver2_patricia_trie_node_reader.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v2/ver2_pt_node_array_reader.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/ver4_dict_buffers.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/ver4_dict_constants.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/ver4_patricia_trie_reading_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/ver4_patricia_trie_writing_helper.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/ver4_pt_node_array_reader.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/dynamic_language_model_probability_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/language_model_dict_content.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/language_model_dict_content_global_counters.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/shortcut_dict_content.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/sparse_table_dict_content.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/terminal_position_lookup_table.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/buffer_with_extendable_buffer.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/byte_array_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/dict_file_writing_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/file_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/forgetting_curve_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/format_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/mmapped_buffer.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/multi_bigram_map.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/probability_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/sparse_table.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/trie_map.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/suggest.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/dicnode/dic_node.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/dicnode/dic_node_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/dicnode/dic_nodes_cache.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/dictionary/dictionary.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/dictionary/dictionary_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/dictionary/digraph_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/dictionary/error_type_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/layout/additional_proximity_chars.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/layout/proximity_info.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/layout/proximity_info_params.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/layout/proximity_info_state.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/layout/proximity_info_state_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/policy/weighting.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/session/dic_traverse_session.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/result/suggestion_results.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/result/suggestions_output_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/gesture/swipe_scoring.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/gesture/swipe_suggest_policy.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/gesture/swipe_traversal.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/gesture/swipe_weighting.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/typing/scoring_params.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/typing/typing_scoring.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/typing/typing_suggest_policy.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/typing/typing_traversal.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/typing/typing_weighting.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/autocorrection_threshold_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/char_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/jni_data_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/log_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/time_keeper.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/ver4_dict_buffers.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/ver4_dict_constants.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/ver4_patricia_trie_node_reader.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/ver4_patricia_trie_node_writer.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/ver4_patricia_trie_policy.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/ver4_patricia_trie_reading_utils.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/ver4_patricia_trie_writing_helper.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/ver4_pt_node_array_reader.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/content/bigram_dict_content.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/content/probability_dict_content.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/content/shortcut_dict_content.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/content/sparse_table_dict_content.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/content/terminal_position_lookup_table.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/backward/v402/bigram/ver4_bigram_list_policy.cpp)

set(LATIN_IME_CORE_TEST_FILES
        ${CMAKE_CURRENT_SOURCE_DIR}/src/defines_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/header/header_read_write_utils_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/language_model_dict_content_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/language_model_dict_content_global_counters_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/probability_entry_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/structure/v4/content/terminal_position_lookup_table_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/bloom_filter_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/buffer_with_extendable_buffer_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/byte_array_utils_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/format_utils_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/probability_utils_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/sparse_table_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/dictionary/utils/trie_map_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/dicnode/dic_node_pool_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/layout/geometry_utils_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/core/layout/normal_distribution_2d_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/suggest/policyimpl/utils/damerau_levenshtein_edit_distance_policy_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/autocorrection_threshold_utils_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/char_utils_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/int_array_view_test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/time_keeper_test.cpp)